From 6095dd2ea7107ca18332a5934803088f239c26b6 Mon Sep 17 00:00:00 2001 From: Dario Faggioli Date: Thu, 24 Mar 2016 15:57:30 +0100 Subject: [PATCH] sched: add .init_pdata hook to the scheduler interface with the purpose of decoupling the allocation phase and the initialization one, for per-pCPU data of the schedulers. This makes it possible to perform the initialization later in the pCPU bringup/assignement process, when more information (for instance, the host CPU topology) are available. This, for now, is important only for Credit2, but it can well be useful to other schedulers. Signed-off-by: Dario Faggioli Reviewed-by: Juergen Gross Reviewed-by: George Dunlap --- xen/common/schedule.c | 7 +++++++ xen/include/xen/sched-if.h | 1 + 2 files changed, 8 insertions(+) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index e57b659f65..0627eb5cdc 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -1517,10 +1517,15 @@ static int cpu_schedule_callback( struct notifier_block *nfb, unsigned long action, void *hcpu) { unsigned int cpu = (unsigned long)hcpu; + struct scheduler *sched = per_cpu(scheduler, cpu); + struct schedule_data *sd = &per_cpu(schedule_data, cpu); int rc = 0; switch ( action ) { + case CPU_STARTING: + SCHED_OP(sched, init_pdata, sd->sched_priv, cpu); + break; case CPU_UP_PREPARE: rc = cpu_schedule_up(cpu); break; @@ -1597,6 +1602,7 @@ void __init scheduler_init(void) if ( ops.alloc_pdata && !(this_cpu(schedule_data).sched_priv = ops.alloc_pdata(&ops, 0)) ) BUG(); + SCHED_OP(&ops, init_pdata, this_cpu(schedule_data).sched_priv, 0); } /* @@ -1640,6 +1646,7 @@ int schedule_cpu_switch(unsigned int cpu, struct cpupool *c) ppriv = SCHED_OP(new_ops, alloc_pdata, cpu); if ( ppriv == NULL ) return -ENOMEM; + SCHED_OP(new_ops, init_pdata, ppriv, cpu); vpriv = SCHED_OP(new_ops, alloc_vdata, idle, idle->domain->sched_priv); if ( vpriv == NULL ) { diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index 825f1adb08..70c08c6b73 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -133,6 +133,7 @@ struct scheduler { void *); void (*free_pdata) (const struct scheduler *, void *, int); void * (*alloc_pdata) (const struct scheduler *, int); + void (*init_pdata) (const struct scheduler *, void *, int); void (*free_domdata) (const struct scheduler *, void *); void * (*alloc_domdata) (const struct scheduler *, struct domain *); -- 2.30.2